<?php

if($dataProviderE->itemCount==0){
	echo '<div class="me-cannotplay"></div>';
}
else{
	$s=Yii::app()->getRequest()->getQuery('s',0);
	$e=Yii::app()->getRequest()->getQuery('e',0);
	if($s==0){
		$sarr=$dataProviderE->getData();
		$s=$sarr[0];
		$e=Episode::model()->findByAttributes(array('eid'=>$s->id));
	}
	else{
		$s=Server::model()->findByPk($s);
		$e=Episode::model()->findByPk($e);
	}
?>
<?php 
	$devide=Tools::checkDevice();
	$html='<video width="100%" height="auto" id="player1" src="'.$s->en_name.$e->link.'" type="video/mp4" controls="controls"></video>';
	if($devide=='wap'){
		$html='<a title="play" class="player_video" href="'.$s->en_name.$e->link.'"><img src="'.Yii::app()->request->baseUrl.'/images/Play_50-1.png"/></a>';
	}
?>
<div class="clip_player"><?php echo $html;?></div>
<?php 
$this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProviderE,
    'itemView'=>'_view',
	'summaryText'=>'',
	'htmlOptions'=>array(
		'class'=>'episode_list',
	),
	'pager' => array(
            'firstPageLabel'=>'Đầu',
            'prevPageLabel'=>'Trước',
            'nextPageLabel'=>'Tiếp',
            'lastPageLabel'=>'Cuối',
            'maxButtonCount'=>0,
     ),
     
));
?>

<?php
	$js='';
				if($devide!='android' && $devide!='android2.1'){
					$js.= '<script type="text/javascript">'.
					  'function loadPlayer(){MediaElement("player1", {success: function(me) {'.
					    'me.play();'.
					    'me.addEventListener("timeupdate", function() {'.
					    //'document.getElementById("time").innerHTML = me.currentTime;'.
						'}, false);'.
						'document.getElementById("pp")["onclick"] = function() {'.
						'if (me.paused){me.play();} else{me.pause();}};'.
					  '}});}
					  loadPlayer();
					  </script>';
				}
				else{
					$js.='<script type="text/javascript">'.
						'function init() {
					      enableVideoClicks();
					    }
					    function enableVideoClicks() {
					      var videos = document.getElementsByTagName("video") || [];
					      for (var i = 0; i < videos.length; i++) {
					        // TODO: use attachEvent in IE
					        videos[i].addEventListener("click", function(videoNode) {
					          return function() {
					            videoNode.play();
					          };
					        }(videos[i]));
					      }
					    }
					    init();
					    </script>';
				}
	echo $js;
?>
<?php 
}
?>